 package client;

 import client.inventory.FamiliarCard;
 import java.io.Serializable;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import server.MapleItemInformationProvider;
 import server.StructItemOption;
 import tools.Randomizer;
 import tools.data.output.MaplePacketLittleEndianWriter;






 public final class MonsterFamiliar
   implements Serializable
 {
   private static final long serialVersionUID = 795419937713738569L;
   private int id;
   private int familiar;
   private int characterid;
   private int exp;
   private String name;
/*  27 */   private short fh = 0;

   private byte grade;

   private byte level;

   private int skill;
   private int option1;
   private int option2;

   public MonsterFamiliar(int id, int characterid, int familiar, String name, byte grade, byte level, int exp, int skill, int option1, int option2, int option3, boolean summon) {
/*  38 */     this.id = id;
/*  39 */     this.familiar = familiar;
/*  40 */     this.characterid = characterid;
/*  41 */     this.name = name;
/*  42 */     this.grade = (byte)Math.min(Math.max(0, grade), 4);
/*  43 */     this.level = (byte)Math.min(Math.max(1, level), 5);
/*  44 */     this.exp = exp;
/*  45 */     this.skill = skill;
/*  46 */     this.option1 = option1;
/*  47 */     this.option2 = option2;
/*  48 */     this.option3 = option3;
/*  49 */     this.summon = summon;
/*  50 */     initPad();
   } private int option3; private int index; private double pad; private boolean summon;
   public MonsterFamiliar() {}
   public MonsterFamiliar(int id, int characterid, int familiar, byte grade) {
/*  54 */     this.id = id;
/*  55 */     this.characterid = characterid;
/*  56 */     this.familiar = familiar;
/*  57 */     this.name = "";
/*  58 */     this.grade = grade;
/*  59 */     this.level = 1;
/*  60 */     this.exp = 0;
/*  61 */     this.skill = Randomizer.rand(800, 904) + 1;
/*  62 */     initPad();
/*  63 */     initOptions();
/*  64 */     this.summon = false;
   }

   public int getOption(int i) {
/*  68 */     switch (i) {
       case 0:
/*  70 */         return this.option1;

       case 1:
/*  73 */         return this.option2;

       case 2:
/*  76 */         return this.option3;
     }

/*  79 */     return 0;
   }


   public int setOption(int i, int option) {
/*  84 */     switch (i) {
       case 0:
/*  86 */         this.option1 = option;

       case 1:
/*  89 */         this.option2 = option;

       case 2:
/*  92 */         this.option3 = option;
         break;
     }
/*  95 */     return 0;
   }


   public void initOptions() {
/* 100 */     LinkedList<List<StructItemOption>> options = new LinkedList<>(MapleItemInformationProvider.getInstance().getFamiliar_option().values());
/* 101 */     for (int i = 0; i < 3; ) {
       while (true) {
/* 103 */         StructItemOption option = ((List<StructItemOption>)options.get(Randomizer.nextInt(options.size()))).get(this.level - 1);
/* 104 */         if (i == 0) {
/* 105 */           if (option.opID / 10000 == this.grade) {
/* 106 */             setOption(i, option.opID); break;
           }
           continue;
         }
/* 110 */         if (option.opID / 10000 == this.grade || option.opID / 10000 == this.grade - 1) {
/* 111 */           setOption(i, option.opID);
           break;
         }
       }
       i++;
     }
   }

   public void initPad() {
/* 120 */     this.pad = ((Float)((Map)MapleItemInformationProvider.getInstance().getFamiliarTable_pad().get(Integer.valueOf(getGrade()))).get(Integer.valueOf(this.level - 1))).floatValue();
   }

   public void gainExp(int exp) {
/* 124 */     this.exp += exp;
/* 125 */     while (this.exp >= 100) {
/* 126 */       this.level = (byte)(this.level + 1);
/* 127 */       this.exp -= 100;
     }
/* 129 */     if (this.level >= 5) {
/* 130 */       this.level = 5;
/* 131 */       this.exp = 0;
     }
/* 133 */     initPad();
   }

   public void updateGrade() {
/* 137 */     this.grade = (byte)(this.grade + 1);
/* 138 */     this.level = 1;
/* 139 */     if (this.grade >= 4) {
/* 140 */       this.grade = 4;
     }
   }

   public double getPad() {
/* 145 */     return this.pad;
   }

   public int getCharacterid() {
/* 149 */     return this.characterid;
   }

   public void setFh(short fh) {
/* 153 */     this.fh = fh;
   }

   public int getGrade() {
/* 157 */     return this.grade;
   }

   public void setGrade(byte grade) {
/* 161 */     this.grade = grade;
   }

   public byte getLevel() {
/* 165 */     return this.level;
   }

   public void setLevel(byte level) {
/* 169 */     this.level = level;
   }

   public int getExp() {
/* 173 */     return this.exp;
   }

   public void setExp(int exp) {
/* 177 */     this.exp = exp;
   }

   public void setSkill(int skill) {
/* 181 */     this.skill = skill;
   }

   public void setOption1(int option1) {
/* 185 */     this.option1 = option1;
   }

   public void setOption2(int option2) {
/* 189 */     this.option2 = option2;
   }

   public void setOption3(int option3) {
/* 193 */     this.option3 = option3;
   }

   public int getIndex() {
/* 197 */     return this.index;
   }

   public void setIndex(int index) {
/* 201 */     this.index = index;
   }

   public int getSkill() {
/* 205 */     return this.skill;
   }

   public void setSkill(short skill) {
/* 209 */     this.skill = skill;
   }

   public int getOption1() {
/* 213 */     return this.option1;
   }

   public void setOption1(short option1) {
/* 217 */     this.option1 = option1;
   }

   public int getOption2() {
/* 221 */     return this.option2;
   }

   public void setOption2(short option2) {
/* 225 */     this.option2 = option2;
   }

   public int getOption3() {
/* 229 */     return this.option3;
   }

   public void setOption3(short option3) {
/* 233 */     this.option3 = option3;
   }

   public int getFamiliar() {
/* 237 */     return this.familiar;
   }

   public int getId() {
/* 241 */     return this.id;
   }

   public final String getName() {
/* 245 */     return this.name;
   }

   public void setName(String n) {
/* 249 */     this.name = n;
   }

   public short getFh() {
/* 253 */     return this.fh;
   }

   public void setFh(int f) {
/* 257 */     this.fh = (short)f;
   }

   public boolean isSummon() {
/* 261 */     return this.summon;
   }

   public void setSummon(boolean summon) {
/* 265 */     this.summon = summon;
   }

   public FamiliarCard createFamiliarCard() {
/* 269 */     return new FamiliarCard((short)this.skill, this.level, this.grade, this.option1, this.option2, this.option3);
   }

   public void writePacket(MaplePacketLittleEndianWriter mplew, boolean bl2) {
/* 273 */     mplew.writeInt(this.id);
/* 274 */     mplew.writeInt(0);
/* 275 */     mplew.writeHexString("02 50 20 64");
/* 276 */     mplew.writeInt(this.familiar);
/* 277 */     mplew.writeAsciiString(this.name, 11);
/* 278 */     mplew.writeShort(0);
/* 279 */     mplew.write(-2);
/* 280 */     mplew.writeShort((short)this.level);
/* 281 */     mplew.writeShort(this.skill);
/* 282 */     mplew.writeShort(131);
/* 283 */     mplew.writeInt(this.exp);
/* 284 */     mplew.writeShort((short)this.level);
/* 285 */     for (int i = 0; i < 3; i++) {
/* 286 */       mplew.writeShort(getOption(i));
     }
/* 288 */     mplew.write(0);
/* 289 */     mplew.write(this.grade);
/* 290 */     mplew.write(bl2 ? 32 : 0);
/* 291 */     mplew.write(bl2 ? 100 : 0);
/* 292 */     mplew.writeHexString("8C FE 66 15");
   }

   public void NewPacket(MaplePacketLittleEndianWriter mplew) {
/* 296 */     mplew.writeInt(this.id);
/* 297 */     mplew.writeInt(0);
/* 298 */     mplew.writeInt(2);
/* 299 */     mplew.writeInt(this.familiar);
/* 300 */     mplew.writeAsciiString(this.name, 11);
/* 301 */     mplew.writeShort(0);
/* 302 */     mplew.write(-2);
/* 303 */     mplew.writeShort((short)this.level);
/* 304 */     mplew.writeShort(this.skill);
/* 305 */     mplew.writeShort(131);
/* 306 */     mplew.writeInt(this.exp);
/* 307 */     mplew.writeShort((short)this.level);
/* 308 */     for (int i = 0; i < 3; i++) {
/* 309 */       mplew.writeShort(getOption(i));
     }
/* 311 */     mplew.write(0);
/* 312 */     mplew.write(this.grade);
/* 313 */     mplew.write(68);
/* 314 */     mplew.write(64);
/* 315 */     mplew.writeInt(1);
   }
 }


/* Location:              C:\PGX\Server.jar!\client\MonsterFamiliar.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */